home *** CD-ROM | disk | FTP | other *** search
/ Aminet 35 / Aminet 35 (2000)(Schatztruhe)[!][Feb 2000].iso / Aminet / util / cli / FixNI.lha / src / fixni.asm < prev    next >
Encoding:
Assembly Source File  |  1999-12-22  |  5.4 KB  |  236 lines

  1. ;*---------------------------------------------------------------------------
  2. ;  :Program.    fixni.asm
  3. ;  :Contents.    fix newicons for OS3.5
  4. ;  :Author.    Bert Jahn
  5. ;  :EMail.    wepl@kagi.com
  6. ;  :Address.    Franz-Liszt-Straße 16, Rudolstadt, 07404, Germany
  7. ;  :Version.    $Id: fixni.asm 1.3 1999/12/22 00:36:33 jah Exp jah $
  8. ;  :History.    15.12.99 initial
  9. ;        19.12.99 fix for selected image depth added
  10. ;             fix for different height added
  11. ;        22.12.99 reworked for public release
  12. ;  :Requires.    OS V37+
  13. ;  :Copyright.    Public Domain
  14. ;  :Language.    68000 Assembler
  15. ;  :Translator.    Barfly V2.9
  16. ;---------------------------------------------------------------------------*
  17. ;##########################################################################
  18.  
  19.     INCDIR    Includes:
  20.     INCLUDE    lvo/exec.i
  21.     INCLUDE    lvo/dos.i
  22.     INCLUDE    lvo/newicon_lib.i
  23.     INCLUDE    workbench/workbench.i
  24.     
  25.     INCLUDE    macros/ntypes.i
  26.  
  27.     STRUCTURE NewDiskObject,0
  28.         APTR    ndo_StdObject        ;The old-style icon
  29.         APTR    ndo_NormalImage        ;May be NULL, meaning no new style icon
  30.         APTR    ndo_SelectedImage    ;May be NULL, meaning no secondary image
  31.         LABEL    ndo_SIZEOF
  32.  
  33.     ifeq 1
  34.  
  35. struct ChunkyImage
  36. {
  37.     UWORD Width;        /* width of the image. Must be <= 93 */
  38.     UWORD Height;       /* height of the image. Must be <= 93 */
  39.     UWORD NumColors;    /* number of pens defined in the palette. Must be <= 256 */
  40.     UWORD Flags;        /* see defines below */
  41.     UBYTE *Palette;     /* array of RGB components of the pens (one byte per gun) */
  42.     UBYTE *ChunkyData;  /* Width*Height bytes storing the colors of the pixels */
  43. };
  44.  
  45. #define CIF_COLOR_0_TRANSP  (1<<0)  /* color 0 is transparent, not the one */
  46.                                     /* stored in palette */
  47.  
  48. #define CIF_DEFAULT         (1<<1)  /* when this bit is set, the image was */
  49.                                     /* obtained via the DEFAULTIMAGE ToolType, */
  50.                                     /* therefore it is not actually part of the */
  51.                                     /* icon and will not be stored in the */
  52.                                     /* ToolTypes on a PutNewDiskObject(). */
  53.     endc
  54.  
  55. ;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  56.  
  57. GL    EQUR    A4        ;a4 ptr to Globals
  58. LOC    EQUR    A5        ;a5 for local vars
  59.  
  60.     STRUCTURE    ArgArray,0
  61.         ULONG    aa_input
  62.         LABEL    aa_SIZEOF
  63.  
  64.     NSTRUCTURE    Globals,0
  65.         NAPTR    gl_execbase
  66.         NAPTR    gl_dosbase
  67.         NAPTR    gl_rdargs
  68.         NSTRUCT    gl_rdarray,aa_SIZEOF
  69.         NALIGNLONG
  70.         NLABEL    gl_SIZEOF
  71.  
  72. ;##########################################################################
  73.  
  74.     PURE
  75.     OUTPUT    C:FixNI
  76.     SECTION    "",CODE
  77.  
  78.         bra    .start
  79.         dc.b    "$VER: FixNI 1.3 "
  80.     DOSCMD    "WDate >t:date"
  81.     INCBIN    "t:date"
  82.         dc.b    " by Bert Jahn <wepl@kagi.com>"
  83.         dc.b    " V37+",0
  84.     CNOP 0,2
  85. .start
  86.  
  87. ;##########################################################################
  88.  
  89.         link    GL,#gl_SIZEOF
  90.         move.l    (4).w,(gl_execbase,GL)
  91.  
  92.         move.l    #37,d0
  93.         lea    (_dosname),a1
  94.         move.l    (gl_execbase,GL),a6
  95.         jsr    _LVOOpenLibrary(a6)
  96.         move.l    d0,(gl_dosbase,GL)
  97.         beq    .nodoslib
  98.  
  99.         lea    (_template),a0
  100.         move.l    a0,d1
  101.         lea    (gl_rdarray,GL),a0
  102.         move.l    a0,d2
  103.         moveq    #0,d3
  104.         move.l    (gl_dosbase,GL),a6
  105.         jsr    (_LVOReadArgs,a6)
  106.         move.l    d0,(gl_rdargs,GL)
  107.         bne    .argsok
  108.         lea    (_readargs),a0
  109.         bsr    _PrintErrorDOS
  110.         bra    .noargs
  111. .argsok    
  112.         bsr    _Main
  113. .opend
  114.         move.l    (gl_rdargs,GL),d1
  115.         move.l    (gl_dosbase,GL),a6
  116.         jsr    (_LVOFreeArgs,a6)
  117. .noargs
  118.         move.l    (gl_dosbase,GL),a1
  119.         move.l    (gl_execbase,GL),a6
  120.         jsr    (_LVOCloseLibrary,a6)
  121. .nodoslib
  122.         unlk    GL
  123.         moveq    #0,d0
  124.         rts
  125.  
  126. ;##########################################################################
  127.  
  128. _Main
  129.     ;open newicon.library
  130.         moveq    #39,d0
  131.         lea    (_niname),a1
  132.         move.l    (gl_execbase,GL),a6
  133.         jsr    (_LVOOpenLibrary,a6)
  134.         tst.l    d0
  135.         bne    .niok
  136.         lea    (_nonilib),a0
  137.         bsr    _Print
  138.         bra    .noni
  139. .niok        move.l    d0,a6
  140.  
  141.     ;remove ".info"
  142.         move.l    (gl_rdarray+aa_input,GL),a0
  143.         move.l    a0,a1
  144. .1        tst.b    (a1)+
  145.         bne    .1
  146.         subq.l    #1,a1
  147.         cmp.b    #"o",-(a1)
  148.         bne    .2
  149.         cmp.b    #"f",-(a1)
  150.         bne    .2
  151.         cmp.b    #"n",-(a1)
  152.         bne    .2
  153.         cmp.b    #"i",-(a1)
  154.         bne    .2
  155.         cmp.b    #".",-(a1)
  156.         bne    .2
  157.         clr.b    (a1)
  158. .2
  159.     ;load icon
  160.         jsr    (_LVOGetNewDiskObject,a6)
  161.         move.l    d0,d7                ;d7 = ndo
  162.         bne    .iconok
  163.         lea    (_loadicon),a0
  164.         bsr    _PrintErrorDOS
  165.         bra    .noobj
  166. .iconok
  167.         move.l    d7,a0
  168.  
  169.     ;check & fix depth for normal image
  170.         move.l    (ndo_NormalImage,a0),d0
  171.         beq    .4
  172.         move.l    d0,a1
  173.         cmp.w    #256,(4,a1)
  174.         bls    .3
  175.         move.w    #256,(4,a1)
  176. .3
  177.     ;check & fix depth for selected image
  178.         move.l    (ndo_SelectedImage,a0),d0
  179.         beq    .6
  180.         move.l    d0,a2
  181.         cmp.w    #256,(4,a2)
  182.         bls    .5
  183.         move.w    #256,(4,a2)
  184. .5
  185.     ;check & fix different height of normal and selected image
  186.         move.w    (2,a1),d0
  187.         cmp.w    (2,a2),d0
  188.         beq    .6
  189.         move.w    d0,(2,a2)
  190. .6
  191.     ;write icon back
  192.         move.l    (gl_rdarray+aa_input,GL),a0
  193.         move.l    d7,a1
  194.         jsr    (_LVOPutNewDiskObject,a6)
  195.  
  196.     ;release icon
  197. .4        move.l    d7,a0
  198.         jsr    (_LVOFreeNewDiskObject,a6)
  199.  
  200.     ;release library
  201. .noobj        move.l    a6,a1
  202.         move.l    (gl_execbase,GL),a6
  203.         jsr    (_LVOCloseLibrary,a6)
  204. .noni
  205.         moveq    #20,d0
  206.         rts
  207.  
  208. ;##########################################################################
  209.  
  210.     INCDIR    Sources:
  211.     INCLUDE    dosio.i
  212.         Print
  213.     INCLUDE    error.i
  214.         PrintErrorDOS
  215.  
  216. ;##########################################################################
  217.  
  218. ; Operationen
  219. _readargs    dc.b    "read arguments",0
  220. _loadicon    dc.b    "load icon",0
  221.  
  222. _nonilib    dc.b    "need newicon.library version 39",10,0
  223.  
  224. ;subsystems
  225. _dosname    dc.b    "dos.library",0
  226. _niname        dc.b    "new"
  227. _iname        dc.b    "icon.library",0
  228.  
  229. _template    dc.b    "INPUTFILE/A"        ;name eines zu ladenden Files
  230.         dc.b    0
  231.  
  232. ;##########################################################################
  233.  
  234.     END
  235.  
  236.